﻿using System;
using System.Web.UI;

namespace AutoCompleteTextBox
{
    public enum MatchVariants
    {
        None,
        charMatch,
        phraseMatch,
        startsWith,
        subWordMatch,
        wordMatch,
    }

    public abstract class AutocompleteDataSource : Control
    {
        public int MaxResults { get; set; }

        public int MinQueryLength { get; set; }

        public int QueryDelay { get; set; }

        public MatchVariants ResultHighlighter { get; set; }

        public MatchVariants ResultFilters { get; set; }

        public bool AllowBrowserAutocomplete { get; set; }

        public bool EnableCache { get; set; }

        public string QueryDelimiter { get; set; }

        public string ResultFormatter { get; set; }

        public bool ActivateFirstItem { get; set; }

        public bool AlwaysShowList { get; set; }

        public bool Circular { get; set; }

        public bool ScrollIntoView { get; set; }

        public bool TabSelect { get; set; }

        public string Align { get; set; }

        
        public AutocompleteDataSource()
        {
            MaxResults = DefaultProperties.DefaultMaxResults;

            MinQueryLength = DefaultProperties.DefaultMinQueryLength;

            QueryDelay = DefaultProperties.DefaultQueryDelay;

            AllowBrowserAutocomplete = DefaultProperties.DefaultAllowBrowserAutocomplete;

            EnableCache = DefaultProperties.DefaultEnableCache;

            ActivateFirstItem = DefaultProperties.DefaultActivateFirstItem;

            AlwaysShowList = DefaultProperties.DefaultAlwaysShowList;

            Circular = DefaultProperties.DefaultCircular;

            ScrollIntoView = DefaultProperties.DefaultScrollIntoView;

            TabSelect = DefaultProperties.DefaultTabSelect;  
        }

        protected override void Render(HtmlTextWriter writer)
        {

        }

        protected virtual SettingsObject GetSettingsObject()
        {
            return new SettingsObject
            {
                MaxResults = MaxResults,
                MinQueryLength = MinQueryLength,
                QueryDelay = QueryDelay,
                ResultHighlighter = ResultHighlighter,
                ResultFilters = ResultFilters,
                AllowBrowserAutocomplete = AllowBrowserAutocomplete,
                EnableCache = EnableCache,
                QueryDelimiter = QueryDelimiter,
                ResultFormatter = ResultFormatter,
                ActivateFirstItem = ActivateFirstItem,
                AlwaysShowList = AlwaysShowList,
                Circular = Circular,
                ScrollIntoView = ScrollIntoView,
                TabSelect = TabSelect,
                Align = Align
            };
        }

        public virtual string RenderDataSource()
        {
            throw new NotImplementedException();
        }

    }
}
